package br.com.onlinebidding.dao;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.persistence.EntityManager;

import br.com.onlinebidding.model.Edict;

public class EdictDAO extends GenericDAO<Edict> {

	private static final long serialVersionUID = 1L;
	private EntityManager em;

	public EdictDAO() {
		super(Edict.class);
	}

	public Edict findEdictByName(String name) {
		Map<String, Object> parameters = new HashMap<String, Object>();
		parameters.put("name", name);
		return super.findOneResult(Edict.FIND_BY_NAME, parameters);
	}

	public Edict findEdictByDateTimeFinish(String dateTimeFinish) {
		Map<String, Object> parameters = new HashMap<String, Object>();
		parameters.put("dateTimeFinish", dateTimeFinish);
		return super.findOneResult(Edict.FIND_BY_DATETIMEFINISH, parameters);
	}

	public List<Edict> findAllAssets() {
		Date date = new Date();
		return em.createNamedQuery(Edict.FIND_ALL_ASSETS, Edict.class)
				.setParameter("getDate", date).getResultList();
	}
}